import { makeAutoObservable } from 'mobx';
import { getIndustryDetail, AddIndustry, getImg, delTask, renderTask, getFile, saveProject } from '@/services/index';
import { Addenvironment, AddItem, saveproject, saveResources, saveTask, saveTList } from '@/utils/addindustry';
class addIndustry {
    constructor() {
        makeAutoObservable(this)
    };
    //添加项目保存后的数据
    addIndustryItem: AddItem = {
        "description": "",
        "id": "",
        "knowledge": [],
        "majorId": "",
        "majorStationList": [],
        "name": "",
        "pictureUrl": "",
        "tradeName": '',
        "majorStationChineseList": [],
        "showUrl": "",
        "stationId": "",
        "subjectTime": 1,
        "sxType": '1',
        "trade": [],
        "tradeId": "",
        "version": 1,
        "versionId": ""
    }
    //添加项目
    async addProject(params: AddItem) {
        //结构
        let { name, version, description, subjectTime, trade, tradeName, majorStationList, pictureUrl, showUrl } = params;
        //深拷贝传过来的数值
        this.addIndustryItem = { ...this.addIndustryItem, name, version, description, subjectTime, trade, tradeName, majorStationList, pictureUrl, showUrl };
        // 调用添加链接
        let result = await AddIndustry(this.addIndustryItem);
        //容错处理
        if (result.data) {
            this.addIndustryItem = result.data;
            return result.data.versionId;
        }
    }
    ProjectDetailImg: string = '';
    //上传图片
    async addProjectImg(data: any) {
        let result = await getImg(data);
        if (result.url)
            this.ProjectDetailImg = result.url
    }
    //编辑详情
    async getIndustryDetail(versionId: string) {
        let result = await getIndustryDetail(versionId);
        //容错处理
        if (result.data) {
            this.addIndustryItem = result.data;
            return result.data
        }
    };
    //添加任务
    addTaskItem: saveTask = {
        "assessmentStandard": '',
        "proVersionId": '',
        "proid": '',
        "steptCount": '',
        "subjectTime": '',
        "taskName": '',
        "id": '',
    };
    //实训环境
    addE: Addenvironment = {
        "id": '',
        "proExperimentalList": [{
            "proId": '',
            "proVersionId": '',
            "exType": 2,
            "exid": '',
            "exDescribes": '',
            "exName": '',
            "exUrl": '',
        }]
    }
    //前置项目保存
    addP: saveproject = {
        "proVersionId": '',
        "bizProIdList": [''],
        "proId": '',
    };
    //上传文件
    RFile: string = '';
    //上传图片
    async getFile(data: any) {
        let result = await getFile(data);
        if (result.url)
            this.RFile = result.url
    };
    //项目资源保存
    addR: saveResources = {
        "id": '',
        "projectResourcesList": [{
            "httpUrl": '',
            "projectReourceAdressList": [],
            "projectVersionId": '',
            "projectid": '',
            "resAdress": '',
            "resDescription": '',
            "resFiletype": 2,
            "resName": '',
            "resType": 10,
            "studentAuthority": '',
            "teacherAuthority": ''
        }]
    };
    //实训大纲
    addT: saveTList = {
        "briefId": '',
        "content": '',
        "proVersionId": ''
    }
}
export default new addIndustry;